let name = '';
Page({
  onLoad() {},
  // 获取openID
  getOpenId() {
    wx.cloud.callFunction({
      name: "getOpenId",
      success: res => {
       
        openId = res.result.openid
        console.log(openId, '获取到了')
      },
      fail: res => {
        console.log(res, '失败')

      }
    })
  },
  // 获取用户授权
  getshouquan() {
    wx.requestSubscribeMessage({
      tmplIds: ['HKBw3ECWROLxKW-JxD8lWhq-ouWhtTZfVRb7IxJb_CY'], //这里填写模板id ，可以同时授权多个模板消息
      success(res) {
        console.log(res, '授权成功')

      },
      fail(res) {
        console.log(res, '授权失败')
      }
    })
  },
  // 发送消息给单个用户
  sedOne() {
    console.log(name)
// return
    wx.cloud.callFunction({
      name: 'dingyue',
      data:{
        openId:'oitUY46zH7VOz6ozoWKdTupYJyRs',
        name:name
      }
    }).then(res => {
      console.log(res, '发送了')

    }).catch(res => {
      console.log(res, '没有发送')
    })
  },
  // 获取用户输入的活动名称
  getName(e){

    name=e.detail.value

  }
})